﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjetAGL
{
    class Pioche : IPioche
    {

        static Random random = new Random();

        public char[] piocher()
        {

            string mot = null;
            string[] lines = System.IO.File.ReadAllLines(@"C:\Mixmo\dico.txt");
            Random randNum = new Random();
            int x = randNum.Next(100000); 
            Boolean trouve = false;

            do
            {
                 x = randNum.Next(100000);
                 if (lines[x].Length == 6)
                 {
                     mot = lines[x];
                     trouve = true;
                 }

            } while (trouve == false);

            
            char[] motdesordre = mot.ToCharArray();

            for (int i = 0; i < motdesordre.Length; i++)
            {
                x = randNum.Next(motdesordre.Length);
                char b = motdesordre[i];
                motdesordre[i] = motdesordre[x];
                motdesordre[x] = b;
            }
                return motdesordre;
        }
    }
}
